<template>
	<view class="template-discovery tn-safe-area-inset-bottom">
		<!-- 图鸟css渐变背景-->
		<view class="bg-fixed">
			<view class="bg-pic" style="position: absolute; right: 0rpx; top: 0rpx">
				<view class="bg-image"
					style="background-image: url('/static/images/home/bg-dudu.png'); background-size: cover"></view>
			</view>
		</view>

		<!-- 写内容-->
		<view :style="{ paddingTop: vuex_custom_bar_height + 10 + 'px' }">
			<view style="padding: 20rpx 30rpx 240rpx 30rpx">
				<view class="tn-text-bold" style="color: #303132; font-size: 50rpx">
					<text class="tn-text-ellipsis">￥{{incomeMonth}}</text>
				</view>
				<view class="tn-padding-top-xs" style="color: #30313280">
					<text class="tn-text-ellipsis">本月收入</text>
				</view>
			</view>

			<!-- 一整个 -->
			<view class="tn-flex tn-flex-wrap" style="padding: 15rpx;">

				<view class="" style="width: 50%;padding: 15rpx;" @click="tn('home/spareRoom')">
					<view class="tn-bg-white" style="border-radius: 24rpx;">
						<view class="" style="padding: 30rpx 30rpx 0 30rpx;">
							<view class="tn-text-lg tn-text-bold" style="color: #303132;">
								<text class="tn-text-ellipsis">闲置房间</text>
							</view>
							<view class="tn-text-sm tn-padding-top-xs" style="color: #ACACAC;">
								<text class="tn-text-ellipsis">{{spareRoom}}</text>
							</view>
						</view>

						<view class="tn-flex tn-flex-row-between tn-flex-col-bottom"
							style="padding: 0 20rpx 20rpx 30rpx;">
							<view class="tn-text-xl"></view>
							<view class="icon5__item--icon tn-flex tn-flex-row-center tn-flex-col-center"
								style="background-image:url('/static/images/home/4444.jpg');background-size:100% 100%;background-size: cover;">
							</view>
						</view>

					</view>
				</view>

				<view class="" style="width: 50%;padding: 15rpx;" @click="tn('home/expiredTenant')">
					<view class="tn-bg-white"
						style="border-radius: 24rpx;box-shadow: 0rpx 0rpx 50rpx 0rpx rgba(0, 0, 0, 0.02);">
						<view class="" style="padding: 30rpx 30rpx 0 30rpx;">
							<view class="tn-text-lg tn-text-bold" style="color: #303132;">
								<text class="tn-text-ellipsis">到期租客</text>
							</view>
							<view class="tn-text-sm tn-padding-top-xs" style="color: #ACACAC;">
								<text class="tn-text-ellipsis">{{expiredTenant}}</text>
							</view>
						</view>

						<view class="tn-flex tn-flex-row-between tn-flex-col-bottom"
							style="padding: 0 20rpx 20rpx 30rpx;">
							<view class="tn-text-xl"></view>
							<view class="icon5__item--icon tn-flex tn-flex-row-center tn-flex-col-center"
								style="background-image:url('/static/images/home/2222.jpg');background-size:100% 100%;background-size: cover;">
							</view>
						</view>

					</view>
				</view>

				<view class="" style="width: 50%;padding: 15rpx;" @click="tn('/discoveryPages/edit')">
					<view class="tn-bg-white" style="border-radius: 24rpx;">
						<view class="" style="padding: 30rpx 30rpx 0 30rpx;">
							<view class="tn-text-lg tn-text-bold" style="color: #303132;">
								<text class="tn-text-ellipsis">本月账单</text>
							</view>
							<view class="tn-text-sm tn-padding-top-xs" style="color: #ACACAC;">
								<text class="tn-text-ellipsis">{{monthlyBillCount}}</text>
							</view>
						</view>

						<view class="tn-flex tn-flex-row-between tn-flex-col-bottom"
							style="padding: 0 20rpx 20rpx 30rpx;">
							<view class="tn-text-xl"></view>
							<view class="icon5__item--icon tn-flex tn-flex-row-center tn-flex-col-center"
								style="background-image:url('/static/images/home/5555.jpg');background-size:100% 100%;background-size: cover;">
							</view>
						</view>

					</view>
				</view>

				<view class="" style="width: 50%;padding: 15rpx;" @click="tn('/discoveryPages/edit')">
					<view class="tn-bg-white" style="border-radius: 24rpx;">
						<view class="" style="padding: 30rpx 30rpx 0 30rpx;">
							<view class="tn-text-lg tn-text-bold" style="color: #303132;">
								<text class="tn-text-ellipsis">今日账单</text>
							</view>
							<view class="tn-text-sm tn-padding-top-xs" style="color: #ACACAC;">
								<text class="tn-text-ellipsis">{{todayBillCount}}</text>
							</view>
						</view>

						<view class="tn-flex tn-flex-row-between tn-flex-col-bottom"
							style="padding: 0 20rpx 20rpx 30rpx;">
							<view class="tn-text-xl"></view>
							<view class="icon5__item--icon tn-flex tn-flex-row-center tn-flex-col-center"
								style="background-image:url('/static/images/home/8787.jpg');background-size:100% 100%;background-size: cover;">
							</view>
						</view>

					</view>
				</view>


			</view>

			<view class="tn-tabbar-height"></view>
		</view>
	</view>
</template>

<script>
	
	import { getStatistics } from "@/api/house/index"
	
	export default {
		name: 'Discovery',
		data() {
			return {
				incomeMonth: 0,
				spareRoom: 0,
				expiredTenant: 0,
				monthlyBillCount: 0,
				todayBillCount: 0
			};
		},
		created() {
			
		  this.getallStatistics()
		},
		methods: {
			handlePageShow() {
			     // 这里是页面每次显示时需要执行的逻辑
			     console.log('Page is shown0')
			   },
			getallStatistics() {
				
				getStatistics().then(response=>{
					console.log("222",response)
					this.incomeMonth=response.data.incomeMonth
					this.spareRoom=response.data.spareRoom
					this.expiredTenant=response.data.expiredTenant
					this.statementAudited=response.data.statementAudited
					this.unpaidBill=response.data.unpaidBill
				})
				
			},
			
			
			
			// 跳转
			tn(e) {
				// 短震动跳转
				wx.vibrateShort();
				uni.navigateTo({
					url: e
				});
			}
		}
	};
</script>

<style lang="scss" scoped>
	.template-discovery {
		max-height: 94vh;
		max-height: calc(94vh + env(safe-area-inset-bottom) / 2);
		max-height: calc(94vh + constant(safe-area-inset-bottom));
	}

	/* 胶囊*/
	.tn-custom-nav-bar__back {
		z-index: 9999;
		width: 100%;
		height: 100%;
		position: relative;
		display: flex;
		justify-content: space-evenly;
		align-items: center;
		box-sizing: border-box;
		color: #ffffff;
		font-size: 40rpx;

		.icon {
			display: block;
			flex: 1;
			margin: auto;
			text-align: center;
		}
	}

	/* 图片 */
	.bg-image {
		margin-top: 140rpx;
		width: 500rpx;
		height: 303rpx;
		position: relative;
		overflow: hidden;
	}

	.bg-pic {
		background-size: cover;
		background-repeat: no-repeat;
		background-position: center;
		overflow: hidden;
	}

	// 四个角渐变底色
	.bg-fixed {
		position: fixed;
		background: linear-gradient(60deg, #dbf2fe, #dbf2fe, #ffe1e1);
		top: 0;
		width: 100%;
		transition: all 0.25s ease-out;
		z-index: -1;
		min-height: 100vh;
	}

	.bg-fixed:before {
		content: '';
		position: absolute;
		top: 0;
		left: 0;
		bottom: 0;
		right: 0;
		z-index: -1;
		mask-image: linear-gradient(to bottom, transparent, black);
		background: linear-gradient(60deg, #f6f7f9, #f6f7f9);
	}

	/* 图标容器5 start */
	.icon5 {
		&__item {
			// width: 30%;
			background-color: #ffffff;
			border-radius: 10rpx;
			padding: 0rpx;
			margin: 0rpx;
			transform: scale(1);
			transition: transform 0.3s linear;
			transform-origin: center center;

			&--icon {
				width: 80rpx;
				height: 80rpx;
				border-radius: 100rpx;
				position: relative;
				z-index: 1;
			}
		}
	}

	/* 底部安全边距 start*/
	.tn-tabbar-height {
		min-height: 180rpx;
		height: calc(200rpx + env(safe-area-inset-bottom) / 2);
		height: calc(200rpx + constant(safe-area-inset-bottom));
	}
</style>